001 /** 002 * Created by IntelliJ IDEA. 003 * User: Wei Wang 004 * Date: Apr 10, 2003 005 * Time: 11:18:01 PM 006 */ 007 008 package EVolve.util.unifyutils; 009 010 import EVolve.data.Entity; 011 import EVolve.visualization.*; 012 import EVolve.Scene; 013 import java.util.*; 014 import java.awt.*; 015 016 public class Unification { 017 018 public static void unifyEntities(HashMap standard, HashMap toBeUnified) { 019 Iterator it = toBeUnified.keySet().iterator(); 020 while (it.hasNext()) { 021 Entity entity = (Entity)toBeUnified.get(it.next()); 022 023 if (!standard.containsKey(entity.getName())) { 024 standard.put(entity.getName(), entity); 025 } 026 } 027 } 028 029 public static void getUnifiedEntity(HashSet fullEntitySet, ArrayList vizList, int dimension) { 030 HashSet dsourceFound = new HashSet(); 031 HashMap standard = new HashMap(); 032 033 for (int i=0; i<vizList.size(); i++) { 034 Visualization visual = (Visualization)vizList.get(i); 035 Integer dsourceId = new Integer(visual.getDataSourceId()); 036 037 if (dsourceFound.contains(dsourceId)) continue; 038 039 dsourceFound.add(dsourceId); 040 041 ReferenceDimension dim = visual.getLinkableDimension(dimension); 042 043 HashMap toBeUnified = Scene.getDataSourceManager().getDataManager(dsourceId.intValue()).getEntity()[dim.getDataFilter().getTargetType()]; 044 045 Unification.unifyEntities(standard, toBeUnified); 046 } 047 048 Iterator it = standard.keySet().iterator(); 049 while (it.hasNext()) { 050 fullEntitySet.add(standard.get(it.next())); 051 } 052 053 } 054 055 public static void changeColor(AutoImage image, Color newColor) { 056 int w = image.getW(); 057 int h = image.getH(); 058 059 for (int i=0; i<w; i++) { 060 for (int j=0; j<h; j++) { 061 Object temp = image.getColor(i,j); 062 if ((temp == null)||(newColor==null)) continue; 063 image.setColor(i, j,newColor); 064 } 065 } 066 } 067 }